//阿里播放器组件配置文档：https://player.alicdn.com/aliplayer/presentation/index.html

//保存当前播放时间 记忆播放组件使用
// const saveTime = function (memoryVideo, currentTime) {
//     if (currentTime > 15) {//观看时间小于15秒不保存
//         localStorage.setItem(memoryVideo, currentTime);
//     }
//
// }
//获取当前播放时间 记忆播放组件使用
// const getTime = function (memoryVideo) {
//     //return返回的是自定义起播时间
//     return localStorage.getItem(memoryVideo)
// }
//播放器组件配置
const player_components = [
    // {
    //     name: 'RateComponent',//倍速播放
    //     type: AliPlayerComponent.RateComponent
    // },
    // {
    //     name: 'QualityComponent',//切换清晰度
    //     type: AliPlayerComponent.QualityComponent,
    //     args: [function (definition, desc) {
    //         console.log(definition + '-----' + desc)
    //     }]
    // },
    // {
    //     name: 'MemoryPlayComponent',//记忆播放（点击）
    //     type: AliPlayerComponent.MemoryPlayComponent,
    //     args: [false, getTime, saveTime]
    // },
    {
        name: 'BulletScreenComponent',//跑马灯
        type: AliPlayerComponent.BulletScreenComponent,
        /** Descriptions of the scrolling text component parameters: text, style, bulletPosition
         * text: The scrolling text
         * style: The style of the scrolling text
         * bulletPosition: The position of the scrolling text. Valid values: 'top', 'bottom', and 'random'. The default is 'random'.
         */
        args: ['uid', {fontSize: '14px', color: "rgba(100%,55%,0%,0.3)"}, 'random']
    }]
//设置跑马灯文本，当没有提供text时从 localStorage.getItem('uid') 获取
const set_bull_screen = function (text) {
    const screen_text = text || localStorage.getItem('uid')
    for (let i of player_components) {
        if (i.name === 'BulletScreenComponent') {
            i.args[0] = screen_text
            break
        }
    }
}
export default player_components
export {set_bull_screen}